home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / machack / Hacks97 / WarriorsProgress.sit / Warrior’s Progress / source code / Source / Libraries / Views / Standard Arrangements / GrowBelowArrangement.cp < prev    next >
Text File  |  1997-06-28  |  3KB  |  160 lines

  1. // GrowBelowArrangement.cp
  2.  
  3. #ifndef GrowBelowArrangement_h
  4. #include "GrowBelowArrangement.h"
  5. #endif
  6. #ifndef MinMax_h
  7. #include "MinMax.h"
  8. #endif
  9.  
  10. GrowBelowArrangement::GrowBelowArrangement( WindowFocus& focus )
  11.   : grow( focus )
  12.   {
  13.     BottomLine().SetView( bottomLine );
  14.     Grow().SetView( grow );
  15.   }
  16.  
  17. void GrowBelowArrangement::Arrange( Rectangle bounds )
  18.   {
  19.     Rectangle grow( bounds.right - barSize,
  20.                          bounds.bottom - barSize,
  21.                          bounds.right,
  22.                          bounds.bottom );
  23.  
  24.     Rectangle main( bounds.left,
  25.                          bounds.top,
  26.                          bounds.right,
  27.                          grow.top );
  28.     
  29.     Rectangle bottomLine( bounds.left,
  30.                                  grow.top,
  31.                                  grow.left,
  32.                                  grow.top + 1 );
  33.     
  34.     Rectangle bottomBar( bounds.left,
  35.                                 bottomLine.bottom,
  36.                                 grow.left,
  37.                                 bounds.bottom );
  38.     
  39.     Main().SetBounds( main );
  40.     Bottom().SetBounds( bottomBar );
  41.     BottomLine().SetBounds( bottomLine );
  42.     Grow().SetBounds( grow );
  43.   }
  44.  
  45. uint16 GrowBelowArrangement::MinimumHeight() const
  46.   {
  47.     uint16 size = Main().Size().MinimumHeight();
  48.     
  49.     Assert( size <= maxint16 - barSize );
  50.     
  51.     return size + barSize;
  52.   }
  53.  
  54. uint16 GrowBelowArrangement::MinimumWidth() const
  55.   {
  56.     uint16 size = Bottom().Size().MinimumWidth();
  57.     
  58.     Assert( size <= maxint16 - barSize );
  59.  
  60.     size += barSize;
  61.     
  62.     return Max( size, Main().Size().MinimumWidth() );
  63.   }
  64.  
  65. uint16 GrowBelowArrangement::MaximumHeight() const
  66.   {
  67.     uint16 size = Main().Size().MaximumHeight();
  68.     
  69.     if ( size >= maxint16 - barSize )
  70.         return maxint16;
  71.     
  72.     return size + barSize;
  73.   }
  74.  
  75. uint16 GrowBelowArrangement::MaximumWidth() const
  76.   {
  77.     uint16 size = Bottom().Size().MaximumWidth();
  78.     
  79.     if ( size >= maxint16 - barSize )
  80.         size = maxint16;
  81.      else
  82.         size += barSize;
  83.     
  84.     return Max( size, Main().Size().MaximumWidth() );
  85.   }
  86.  
  87. uint16 GrowBelowArrangement::ReasonableHeight() const
  88.   {
  89.     uint16 size = Main().Size().ReasonableHeight();
  90.     
  91.     Assert( size <= maxint16 - barSize );
  92.     
  93.     return size + barSize;
  94.   }
  95.  
  96. uint16 GrowBelowArrangement::ReasonableWidth() const
  97.   {
  98.     uint16 size = Bottom().Size().ReasonableWidth();
  99.     
  100.     Assert( size <= maxint16 - barSize );
  101.     
  102.     size += barSize;
  103.     
  104.     return Max( size, Main().Size().ReasonableWidth() );
  105.   }
  106.  
  107. uint16 GrowBelowArrangement::BestHeight() const
  108.   {
  109.     uint16 size = Main().Size().BestHeight();
  110.     
  111.     Assert( size <= maxint16 - barSize );
  112.     
  113.     return size + barSize;
  114.   }
  115.  
  116. uint16 GrowBelowArrangement::BestHeight( uint16 bound ) const
  117.   {
  118.     if ( bound <= barSize )
  119.         return bound;
  120.     
  121.     bound -= barSize;
  122.  
  123.     uint16 size = Main().Size().BestHeight( bound );
  124.     size = Min( size, bound );
  125.     
  126.     Assert( size <= maxint16 - barSize );
  127.     
  128.     return size + barSize;
  129.   }
  130.  
  131. uint16 GrowBelowArrangement::BestWidth() const
  132.   {
  133.     uint16 size = Main().Size().BestWidth();
  134.     
  135.     Assert( size <= maxint16 - barSize );
  136.     size += barSize;
  137.     
  138.     size = Min( size, Bottom().Size().MaximumWidth() );
  139.     size = Max( size, Bottom().Size().MinimumWidth() );
  140.     
  141.     return size - barSize;
  142.   }
  143.  
  144. uint16 GrowBelowArrangement::BestWidth( uint16 bound ) const
  145.   {
  146.     uint16 size = Main().Size().BestWidth( bound );
  147.  
  148.     Assert( size <= maxint16 - barSize );
  149.     size += barSize;
  150.     
  151.     size = Min( size, Bottom().Size().MaximumWidth() );
  152.     size = Max( size, Bottom().Size().MinimumWidth() );
  153.     
  154.     size -= barSize;
  155.     
  156.     size = Min( size, bound );
  157.         
  158.     return size;
  159.   }
  160.